package 曾世昌12_8.zuoye26;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.List;

public class test {
    public static void main(String[] args) throws Exception {
        List<String> strings = FileUtils.readLines( new File( "E:\\untitled5\\src\\rc\\mxdx3_zhoumozuoye\\zuoye26\\data.properties" ) );
        Class<?> aClass = Class.forName( "rc.mxdx3_zhoumozuoye.zuoye26.User" );
        Method setUid = aClass.getDeclaredMethod( "setUid", String.class );
        setUid.setAccessible( true );
        Method setUsername = aClass.getDeclaredMethod( "setUsername", String.class );
        setUid.setAccessible( true );
        Method setPassword = aClass.getDeclaredMethod( "setPassword", String.class );
        setUid.setAccessible( true );
        Constructor<?> constructor = aClass.getConstructor();
        Object o = constructor.newInstance();
        for (int i = 0; i < strings.size(); i++) {
            String[] split = strings.get( i ).split( "=" );
            for (int i1 = 0; i1 < split.length; i1++) {
                if (split[0].equals( "uid" )) {
                    setUid.invoke( o, split[1] );
                }
                if (split[0].equals( "username" )) {
                    setUsername.invoke( o, split[1] );
                }
                if (split[0].equals( "password" )) {
                    setPassword.invoke( o, split[1] );
                }
            }
        }
    }
}
